import React, { Component } from 'react';
import {
    View,
    Dimensions,
    StyleSheet,
    ListView,
    TouchableOpacity,
    Platform,
    WebView
} from 'react-native';
import { Content, Text, Icon } from 'native-base';
import { NavigationActions } from 'react-navigation';
import BDPlayerView from '../../modules/BDPlayer.js';
import { connect } from 'react-redux';
const { width, height } = Dimensions.get('window');
const marginTop = Platform.OS === 'ios' ? 20 : 0;

class Video extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        const { resourseURL } = this.props;
       /*  console.log('videoresourseURL');
        console.log(resourseURL.resourseURL);  */

       if (Platform.OS === 'ios') {
           console.log(resourseURL.resourseURL); 
            return (
                <View style={{ flex: 1 }}>
                    <WebView style={styles.webview_style}
                        source={{ uri:resourseURL.resourseURL }}//resourseURL.resourseURL{uri: this.state.url}
                        scalesPageToFit={true}
                    >
                    </WebView>
                </View>
            );
        } 
         if (Platform.OS === 'android') {
             console.log(resourseURL.resourseURL); 
            return (
                <View style={{ flex: 1 }}>
                    <BDPlayerView source={resourseURL.resourseURL} //'http://119.97.166.135:80/data/userdata/vod/resource/201611/ssZz3tGx.mp4'resourseURL.resourseURL
                        style={{ height: height / 2, width: width }} />
                </View>
            );
         }
    }
}




var styles = StyleSheet.create(
    {
        webview_style: {

        },
    });
function mapStateToProps(state) {
    return { resourseURL: state.course.resourseURL }
}

function mapDispatchToProps(dispatch) {
    return {
    }
}

const VideoPage = connect(
    mapStateToProps,
    mapDispatchToProps
)(Video)
export default VideoPage;
